package com.ljy.my_study.java.fieldquery;

import java.lang.reflect.Field;

/**
 * @author lijunying
 * @date 2021/5/27 15:36
 */
public class TestMain {

    public static void main(String[] args) throws ClassNotFoundException, IllegalAccessException {
        Class<Person> personClass= (Class<Person>) TestMain.class.getClassLoader().loadClass("com.ljy.my_study.java.fieldquery.Person");
        Field[] fields=personClass.getDeclaredFields();
        for(Field f:fields){
            System.out.println(f.getName()+":"+f.get(null));
        }

        for(Class c:personClass.getClasses()){
            System.out.println(c.getClass());
            Field[] innerClassFields=c.getDeclaredFields();
            for(Field f:innerClassFields){
                ConstsFieldDescription fd=f.getAnnotation(ConstsFieldDescription.class);
                System.out.println(fd.value());
            }
        }
    }
}
